package com.campus.common.repairTechnician.service.impl;

import com.campus.common.repairTechnician.entity.RepairTechnician;
import com.campus.common.repairTechnician.entity.dto.AddRepairTechnicianDTO;
import com.campus.common.repairTechnician.mapper.RepairTechnicianMapper;
import com.campus.common.repairTechnician.service.IRepairTechnicianService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.campus.common.result.Result;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 维修人员表 服务实现类
 * </p>
 *
 * @author author
 * @since 2024-11-18
 */
@Service
public class RepairTechnicianServiceImpl extends ServiceImpl<RepairTechnicianMapper, RepairTechnician> implements IRepairTechnicianService {

    @Override
    public Result addRepairTechnician(AddRepairTechnicianDTO addRepairTechnicianDTO) {
        RepairTechnician repairTechnician = new RepairTechnician();
        BeanUtils.copyProperties(addRepairTechnicianDTO,repairTechnician);
        int i=baseMapper.insert(repairTechnician);
        if(i==1){
            return Result.success();
        }
        return Result.fail("添加失败");
    }

    @Override
    public Result editRepairTechnician(RepairTechnician repairTechnician) {

        int i=baseMapper.updateById(repairTechnician);
        if(i==1){
            return Result.success();
        }
        return Result.fail("修改失败");
    }
}
